package cn.changhong.user.model.vo;

import cn.changhong.user.model.User;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @Author zz
 * @Date
 **/
public class ListUserVO {
    Integer count;
    List<UserVO> userList;


    @Override
    public String toString() {
        return "ListUserVO{" +
                "count=" + count +
                ", userList=" + userList +
                '}';
    }

    public List<UserVO> getUserList() {
        return userList;
    }

    public void setUserList(List<User> userList) {
        List<UserVO> userVOList=new ArrayList<>();
        Iterator<User> itr = userList.iterator();
        while (itr.hasNext()){
            User user=itr.next();
            UserVO userVO=new UserVO();
            userVO.setNickname(user.getNickname());
            userVO.setEmail(user.getEmail());
            userVO.setAvatar(user.getAvatar());
            userVO.setCreateTime(user.getCreateTime());
            userVO.setStatus(user.getStatus());

            String role;
            if(user.getRoleId() == 1){
                role="超级管理员";
            }else if(user.getRoleId() == 2){
                role="管理员";
            }else {
                role="普通用户";
            }
            userVO.setRole(role);
            userVOList.add(userVO);
        }
        this.userList = userVOList;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }
}
